package com.fourth.controller;
import com.fourth.dao.UBaddrDao;
import com.fourth.service.AddrService;
import com.ljx.entity.Addr;
import com.ljx.vo.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


/**
 * @author C-Q
 * @version 1.1.0
 * @Description: 用户信息
 * @date 2023/3/2
 */
@RestController
@RequestMapping("/merchant")
public class UBaddrController {


    @Resource
    private UBaddrDao uBaddrDao;

    @Resource
    private AddrService addrService;
    /**
     * 查询addr所有地址
     * @return
     */
    @RequestMapping("/UserAddr")
    public Result UserAddr(){
        return addrService.SelectAll();

    }
    /**
     * 根据当前地址id删除
     * @return
     */
    @RequestMapping("/DeleteAddr")
    public Result DeleteAddr(String id){
        int i = uBaddrDao.deleteById(id);
        return new Result(2000,"删除成功",i);
    }
    /**
     * 根据用户名添加地址
     * @return
     */
    @RequestMapping("/insertAddr")
    public Result insertAddr(@RequestBody Addr addr){
        System.out.println(addr);
        return addrService.AddrInsert(addr);
    }
    /**
     * 根据id修改地址
     * @return
     */
    @RequestMapping("/updateId")
    public Result updateId(@RequestBody Addr addr){
        int i = uBaddrDao.updateById(addr);
        return new Result(2000,"修改成功",i);
    }
}
